package main

import (
	"fmt"
	"sync"
)

func main() {

	wg := sync.WaitGroup{}
	wg.Add(3)

	aChan := make(chan int)
	bChan := make(chan int)
	cChan := make(chan int)

	aChan <- 0
	go func() {
		for i := 0; i < 10; i++ {
			ball := <-aChan
			fmt.Println("a")
			bChan <- ball
		}

		wg.Done()
	}()

	go func() {
		for i := 0; i < 10; i++ {
			ball := <-bChan
			fmt.Println("b")
			cChan <- ball
		}
		wg.Done()
	}()

	go func() {
		for i := 0; i < 10; i++ {
			ball := <-cChan
			fmt.Println("c")
			aChan <- ball
		}

		wg.Done()
	}()

	wg.Wait()

}
